package com.jed.xxh.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jed.xxh.R;
import com.jed.xxh.entity.NewsData;
import com.jed.xxh.utils.PicassoUtil;

import java.util.List;

/**
 * 项目名：SmartButler<br/>
 * 包名：  com.jed.xxh.adapter<br/>
 * 作者：徐晓辉<br/>
 * 创建日期：2018/11/29 17:18<br/>
 * 描述：头条新闻adapter<br/>
 */
public class NewsAdapter extends MyBaseAdapter {

    private List<NewsData> mList;

    private NewsData mData;

    public NewsAdapter(List<NewsData> mList) {
        super(mList);
        this.mList = mList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if (convertView == null) {
            holder = new Holder();
            convertView = inflater.inflate(R.layout.news_itme, null);
            holder.iv_img = convertView.findViewById(R.id.iv_img);
            holder.tv_title = convertView.findViewById(R.id.tv_title);
            holder.tv_author_name = convertView.findViewById(R.id.tv_author_name);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        mData = mList.get(position);
        holder.tv_title.setText(mData.getTitle());
        holder.tv_author_name.setText(mData.getAuthor_name());
        PicassoUtil.loadImgView(mData.getThumbnail_pic_s(),holder.iv_img);
        return convertView;
    }

    class Holder {
        private ImageView iv_img;
        private TextView tv_title;
        private TextView tv_author_name;

    }
}
